# Maintainer(Arch): Felix Yan <felixonmars@archlinux.org>
# Contributor: Benoît Allard <benoit dot allard at gmx dot de>
# Contributor: killruana <killruana@gmail.com>
# Maintainer: Sagar Acharya <sagar@hyperbola.info>

pkgname=yosys
pkgver=0.14
pkgrel=1
pkgdesc='A framework for RTL synthesis'
arch=('x86_64')
url='http://www.clifford.at/yosys/'
license=('ISC')
depends=('abc' 'bash' 'boost-libs' 'tcl' 'libffi' 'python' 'protobuf')
makedepends=('boost')
checkdepends=('iverilog')
optdepends=('graphviz: Schematics display support'
            'xdot: Display netlists')
source=("https://github.com/YosysHQ/yosys/archive/refs/tags/$pkgname-$pkgver.tar.gz")
sha512sums=('a32af50328e6d294b565cab7a0938f795bddf02540fa5a3bc709fc4826450745049776fe1f1d3f829c6f73bbca5e5f690337b06ce0d613362b478234a5f3fcc7')

_make() {
    make \
        PREFIX="/usr" \
        CONFIG=gcc \
        ENABLE_TCL=1 \
        ENABLE_ABC=1 \
        ENABLE_GLOB=1 \
        ENABLE_PLUGINS=1 \
        ENABLE_LIBYOSYS=1 \
        ENABLE_PROTOBUF=1 \
        ENABLE_ZLIB=1 \
        ENABLE_PYOSYS=1 \
        ABCEXTERNAL=abc \
        BOOST_PYTHON_LIB="-lpython3.8 -lboost_python38" $@
}

build() {
    cd $pkgname-$pkgname-$pkgver
    _make
}

#check() {
#    cd $pkgname-$pkgname-$pkgver
#    _make test
#}

package() {
    cd $pkgname-$pkgname-$pkgver
    _make DESTDIR="$pkgdir" PYTHON_PREFIX="$pkgdir/usr" install
    install -Dm644 COPYING -t "$pkgdir"/usr/share/licenses/$pkgname/
}
